//
//  SQLitemanager.h
//  PiPiPineapple
//
//  Created by 李晓东 on 17/11/1.
//  Copyright © 2017年 PeanutXu. All rights reserved.
//

#import <UIKit/UIKit.h>
@protocol SQLiteManagerQueryDelegate
- (void)loadDataFromSQLite3:(NSArray *)array andIssueno:(NSString *)issueno;
@end

typedef void(^RetuenBlock)(NSArray *array, BOOL needRefresh);

@interface SQLiteManager : NSObject
@property (nonatomic, strong) id<SQLiteManagerQueryDelegate> delegate;

+ (instancetype)share;
- (void)insertDataOfArray:(NSArray *)array orDictionary:(NSDictionary *)dict inTable:(NSString *)tableName;

/**
 按条件查询
 这里用到了形参个数可变的方法,传值顺序是 key, value, key, value...
 @param tableName 表名
 @param obj 这里暂时还没用到
 @param key 条件查询的 key
 @param value  条件查询的 value
 
 */
- (void)queryDataInTable:(NSString *)tableName andOrderBy:(id)obj withParameter:(NSString *)key andValue:(NSString *)value ,...;

/// 与上面的方法逻辑一样,只是多了一个 block
- (void)queryDataInTable:(NSString *)tableName andReturn:(RetuenBlock)returnBlock andOrderBy:(id)obj withParameter:(NSString *)key andValue:(NSString *)value ,...;
/**
 按条件查询

 @param tableName 同上
 @param obj 同上
 @param key 同上
 @param values 同上
 @param operate 比较的类型,如 >, <>, >=...
 */
- (void)queryDataInTable:(NSString *)tableName andOrderBy:(id)obj withParameter:(NSString *)key andValue:(NSString *)values andOperate:(NSString *)operate, ...;

/// 刷新
- (void)queryDataInTable:(NSString *)tableName andReturnBlock:(RetuenBlock)returnBlock andOrderBy:(id)obj andSort:(NSString *)sort andResultCount:(NSInteger)count withParameter:(NSString *)key andOperate:(NSString *)operate andValue:(NSString *)value ,...;
@end
